package com.androidhuman.example.layoutsample;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class LayoutList extends ListActivity {
	String[] items = new String[]{
			"LinearLayout",
			"RelativeLayout",
			"FrameLayout",
			"TableLayout",
			"ScrollVeiw"
	};

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.main);
	    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items);
	    
	    setListAdapter(adapter);
	
	    // TODO Auto-generated method stub
	}
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		int resId;
		switch(position){
		case 0:
			resId = R.layout.linear;
			break;
		
		case 1:
			resId = R.layout.relative;
			break;

		case 2:
			resId = R.layout.frame;
			break;
			
		case 3:
			resId = R.layout.table;
			break;
			
		case 4:
			resId = R.layout.scroll;
			break;
			
		default:
			throw new IllegalStateException();
		
		}
		startActivity(new Intent(this, LayoutPreview.class).putExtra("layout_id", resId));
	}

}
